home *** CD-ROM | disk | FTP | other *** search
- '*******************************PENTIUM.BAS*****************************
- 'Hi:
- '
- 'Trying to understand what all the hoopla in the new papers and on
- 'Internet is over discovering that the Pentium chip.... like all CPUs...
- 'makes a "floating point" math error.
- '
- 'If you do long division math (using numbers with decimal places)
- 'with a computers, you "always" get some "rounding errors."
- 'I think that is true for all computers, not sure but think so.
- '
- 'Apparently the Internet community is up in arms because they don't know,
- 'that. Or... else, everyone on the facility of State U just wants Intel
- 'to buy them a new computer!
- '
- 'The formula given in the New York Times November 24th, 1994
- 'was:
- ' 4,195,835 -[(4,195,835/3,145,727)*3,145,727] = Answer
- '
- 'The "Answer" is Zero, but with this formula and a Pentium chip, the
- 'answer is "256" or an error of 256/4,195,835 or 61/100,000.
- '
- 'A teeny tiny error unless you are looking to set a new world's record
- 'in "prime numbers" as the math person in New York was trying to do when
- 'he discovered this little Pentium chip crack.
- '
- 'You get a zero (0); because that formula divides the first number by a
- 'second number to get a fraction (a long division or floating point number)
- 'then multiplies that result by the second number.
- '
- 'It should be very clear to anyone but the hopelessly lost on Internet
- 'that a number divided by a second number and then multiplied by that second
- 'number is always (always!!!) zero.
-
- 'But with computers that last statement just ain't necessarily so....
- '
- '
- 'So.... I have taken it upon myself to give you a little program that
- 'will show you that your very own beloved computer of whatever make
- 'and kind will do just what the Intel Pentium chip does.... give
- 'you long division errors.
-
- 'If you have a Pentium computer and a less prestigious one, run this test
- 'on both of them. Get back to me if you find big differences in the amount
- 'of errors.
- '
- 'This program is compiled into a stand-alone *.EXE file and as PENTIUM.BAS.
- 'PENTIUM.BAS can be transmitted via ASCII type E-Mail to Internet so that
- 'those non-mathematical, non-computer types on Internet can
- 'run it and -maybe- add some light to the flaming and heat there.
- '
- 'Use the batch file RUN.BAT as it will start your QBASIC.EXE program
- '(comes with DOS 5 and newer) and runs this program.
- '
- 'Get back to me.... I'm really curious to find out if the Pentium is
- 'really worser than the 286, 386, 486 CPUs.
- '
- 'To run this program with QBASIC.EXE, just open it in that program
- 'and "RUN" it or use RUN.BAT which came with this file set.
- '
- 'John De Palma on CompuServe 76076,571
- '
- 'Wed 12-07-1994 02:10:17
- '===================================================================
-
- DEFINT A-Z
- CONST True = -1, False = 0
-
- DECLARE SUB LapsedTimer (TimerRow%, TimerCol%, Colr%)
- DECLARE SUB Splash1 ()
- DECLARE SUB PressAnyKey ()
- DECLARE SUB IsCursor (IfTrue%)
- DECLARE SUB TextInput (text$, MaxLen%)
- DECLARE SUB TextBoxShadow (Row%, Col%, Message$, Outline%, Shadow%, Length%)
- DECLARE FUNCTION Rounded# (number#, Places%)
- DECLARE SUB RunRan (Samples&)
- DECLARE SUB LocateIt (Row%, text$)
- DECLARE SUB Splash2 (Choice%)
- DECLARE SUB TwoColrs (Fgd%, Bkg%, Colr%)
- DECLARE FUNCTION Center% (text$)
- DECLARE FUNCTION YesNo2% (Answer$)
- REDIM SHARED Box$(1 TO 56)
- BaseRow% = 2
- Q$ = CHR$(34)
- IsCursor (False)
- COLOR 15, 1
- CLS
- CALL Splash1
- SLEEP 8
- CALL PressAnyKey
- Again:
- ReStart% = True
- COLOR 15, 1
- CLS
- CALL Splash2(10)
- 'TextBoxShadow (Row%, Col%, Message$, Outline%, Shadow%, Length%)
- Message$ = "Long Division or " + Q$ + "PENTIUM" + Q$ + " Test"
- Row% = BaseRow%: Col% = 0: Outline% = 5: Shadow% = True: Length% = False
- CALL TextBoxShadow(Row%, Col%, Message$, Outline%, Shadow%, Length%)
-
-
- text$ = "The Number of tests to Run"
- Row% = BaseRow% + 5: Col% = 0: Outline% = 1: Shadow% = True: Length% = 1
- Message$ = SPACE$(LEN(text$))
- CALL TextBoxShadow(Row%, Col%, Message$, Outline%, Shadow%, Length%)
- CALL LocateIt(BaseRow% + 6, text$)
-
- text$ = SPACE$(6)
- COLOR 11, 0
- CALL LocateIt(BaseRow% + 7, text$)
- IsCursor (True)
- LOCATE BaseRow% + 7, Center%(text$)
-
- MaxLen% = 5
- text$ = ""
- CALL TextInput(text$, MaxLen%)
- Samples& = VAL(text$)
- IF Samples& = 0 THEN END
-
- Message$ = SPACE$(30)
- COLOR 11, 0
- Row% = BaseRow% + 11: Col% = 0: Outline% = 4: Shadow% = True: Length% = 7
- CALL TextBoxShadow(Row%, Col%, Message$, Outline%, Shadow%, Length%)
- CALL RunRan(Samples&)
- CALL PressAnyKey
- GOTO Again
- END
-
- FUNCTION Center% (text$)
- Center% = 41 - LEN(text$) \ 2
- END FUNCTION
-
- SUB ColorIt (Fgd, Bkg)
- COLOR Fgd, Bkg
- END SUB
-
- SUB DateTime (Row%, Col%, Colr%)
-
- CALL TwoColrs(Fgd%, Bkg%, Colr%)
- COLOR Fgd%, Bkg%
- StartTime! = TIMER
- text$ = "Lapsed Time: " + DATE$ + " Time: " + TIME$
- Message$ = SPACE$(LEN(text$) \ 2)
- 'TextBoxShadow (Row%, Col%, Message$, Outline%, Shadow%, Length%)
- CALL TextBoxShadow(Row%, Col%, Message$, 0, False, 1)
- LOCATE Row% + 1, Col% + 1: PRINT "DATE: "; DATE$
- LOCATE Row% + 2, Col% + 1: PRINT "Time: "; TIME$
-
-
- END SUB
-
- SUB Delay (DelayTime!) STATIC
- 'I don't like this timer
- StartTime! = TIMER
-
- Start! = TIMER
-
- IF Start! + DelayTime! > 86400 THEN
- Finish! = Start! + DelayTime! - 86400
-
- DO WHILE TIMER >= Start! OR TIMER <= Finish!
- LOOP
-
- ELSE
- DO WHILE TIMER <= Start! + DelayTime!
- LOOP
- END IF
-
- END SUB
-
- SUB GetColr (Fgd%, Bkg%, Colr%) STATIC
-
- Colr% = SCREEN(1, 1, 1)
-
- Fgd% = (Colr% AND 128) \ 8 + (Colr% AND 15)
- Bkg% = (Colr% AND 112) \ 16
-
- END SUB
-
- SUB IsCursor (IfTrue%)
- 'Like this better than two SUBs of CursorOn and CursorOff
- 'Especially with the trouble changing the code with QuickPak
- 'and PDQ
- IF IfTrue% = True THEN
- LOCATE , , 1, 4, 7 'big cursor
- 'LOCATE , , 1
- ELSE
- LOCATE , , 0
- END IF
- END SUB
-
- SUB LapsedTimer (TimerRow%, TimerCol%, Colr%) STATIC
- STATIC Start&, LapsedTime&, StartFlag%
-
- IF StartFlag% = False THEN
- Start& = TIMER
- LapsedTime& = TIMER - Start&
- StartFlag% = True
- ELSE
- IF TIMER >= 86400 THEN 'should trap passing midnight???
- LapsedTime& = (TIMER - Start&) - 86400
- ELSE
- LapsedTime& = (TIMER - Start&)
- END IF
- END IF
-
- CALL TwoColrs(Fgd%, Bkg%, Colr%)
- COLOR Fgd%, Bkg%
- text$ = "Seconds" '+ STR$(LapsedTime!)
-
- Message$ = SPACE$((LEN(text$)) - 4)
- 'TextBoxShadow (Row%, Col%, Message$, Outline%, Shadow%, Length%)
- CALL TextBoxShadow(TimerRow%, TimerCol%, Message$, 0, True, 1)
- LOCATE TimerRow% + 1, TimerCol% + 1: PRINT text$
- LOCATE TimerRow% + 2, TimerCol% + 1: PRINT LapsedTime&
-
- END SUB
-
- DEFSNG A-Z
- SUB LocateIt (Row%, text$)
- LOCATE Row%, 41 - (LEN(text$)) \ 2
- PRINT text$;
- END SUB
-
- DEFINT A-Z
- SUB OriginalTest
- 'from Article in NY Times Nov 24, 1994 as presented by
- 'Cleve Moller (sp?) from MathWorks (a software company that sell a
- 'big time statistical package
- 'to test the Pentium chip's ability.... or its lack there of rounding
- 'beyond -five- decimal places.
- 'following is based on the formula in above article.
- 'result? Pentium's error is larger
- Divisor# = 4195835
- Dividend# = 3145727
- FloatNum# = Divisor# / Dividend#
- Answer# = Divisor# - ((Divisor# / Dividend#) * Dividend#)
-
- 'STOP
- FivePlace# = Rounded#(FloatNum#, -5)
- PRINT "Divided Number is: ";
- PRINT USING "#.###############"; FloatNum#
- PRINT "Rounded Number is: ";
- PRINT USING "#.###############"; FivePlace#
- PRINT "Subtract Rounded from Full number: ";
- PRINT USING "#.###############"; FloatNum# - FivePlace#
- Answer2# = Divisor# - (FivePlace# * Dividend#)
- PRINT "Correct Answer is: ";
- PRINT USING "#.###############"; Answer#
- PRINT "Rounded Answer is: ";
- PRINT USING "#.###############"; Answer2#
- PRINT "Pentium Chip Answer is: ";
- Answer3# = Divisor# - ((1.3337391#) * Dividend#)
- PRINT USING "###.###############"; Answer3#
- PRINT "=Difference= between rounded and Pentium is: ";
- PRINT USING "#.###############"; FloatNum# - 1.3337391#
-
- END SUB
-
- SUB Pause (Seconds!)
-
- Synch! = TIMER
- DO 'looping changes the Start! time to
- Start! = TIMER 'synchronize to the system timer
- LOOP WHILE Start! = Synch! 'Seconds! must be SINGLE to get fractions
- 'of a second
- DO
- Kee$ = INKEY$
- LOOP UNTIL TIMER > (Start! + Seconds!) OR LEN(Kee$)
-
- 'put Kee$ in just in case we pass midnight
- WHILE INKEY$ <> "": WEND 'delete that key stroke
- END SUB
-
- SUB PressAnyKey
-
- text$ = " PRESS: A Key to Continue... "
- Row% = CSRLIN
- Col% = POS(0)
- Colr% = SCREEN(Row%, Col%, 1)
- CALL TwoColrs(Fgd%, Bkgd%, Colr%)
- COLOR 11, 0
- LOCATE 24, Center(text$)
- GOSUB StoreText
-
- PRINT text$;
- COLOR Fgd%, Bkgd%
- WHILE INKEY$ = "": WEND
- WHILE INKEY$ <> "": WEND 'need this to remove the key press
- LOCATE 24, Center(text$)
- PRINT StoreScreenLine$;
- 'PRINT SPACE$(LEN(text$));
- LOCATE Row%, Col%
- EXIT SUB
- StoreText:
-
- FOR i% = 1 TO LEN(text$)
- StoreScreenLine$ = StoreScreenLine$ + CHR$(SCREEN(CSRLIN, i%))
- NEXT
- RETURN
- END SUB
-
- FUNCTION Rounded# (number#, powerOfTen%) STATIC
-
- 'rounds using power of ten, two places for dollars
- TenPower# = 10# ^ powerOfTen%
- Rounded# = INT(number# / TenPower# + .5#) * TenPower#
-
- END FUNCTION
-
- SUB RunRan (Samples&)
-
- Fgd% = 11
- Bkgd% = 0
- COLOR Fgd%, Bkgd%
- BaseRow% = CSRLIN - 9
- BaseCol% = 26
- 'STOP
- RANDOMIZE TIMER
- Num$ = STRING$(16, "#")
- ' LOCATE BaseRow% - 2, BaseCol%
- ' PRINT "Answer = FirstNum - ((FirstNum/SecondNum) * FirstNum)"
- MakeSound& = Samples& / 100
- FOR i& = 1 TO Samples&
- D1# = INT(RND * 10 ^ 7)
- D2# = INT(RND * 10 ^ 7)
- Ans# = D1# - ((D1# / D2#) * D2#)
- LOCATE BaseRow%, BaseCol%
- IF NOT Ans# = 0 THEN
- ErrorCount& = ErrorCount& + 1
- COLOR 12, Bkgd%
- PRINT "Answer: ";
- PRINT USING "#." + Num$; Ans#;
- COLOR 14, Bkgd%
- SoundCount& = SoundCount& + 1
- IF SoundCount& >= MakeSound& THEN
- SOUND 64, 1
- 'PLAY "p64"
- SoundCount& = 0
- END IF
- Row% = BaseRow% + 2: Col% = 4: Outline% = 5: Shadow% = True: Length% = 1
- Message$ = SPACE$(LEN(STR$(ErrorCount&) + "ERROR(s)") \ 2)
- COLOR 15, 4
- CALL TextBoxShadow(Row%, Col%, Message$, Outline%, Shadow%, Length%)
- LOCATE BaseRow% + 3, Col% + 2
- PRINT "ERROR(s)"
- LOCATE BaseRow% + 4, Col% + 3
- PRINT ErrorCount&
- ELSE
- COLOR 14, Bkgd%
- PRINT "Answer: ";
- PRINT USING "#." + Num$; Ans#;
- END IF
- COLOR Fgd%, Bkgd%
- LOCATE BaseRow% + 2, BaseCol%
- PRINT "Count:"; i&
- LOCATE BaseRow% + 3, BaseCol%
- TotD1# = TotD1# + D1#
- PRINT "Sum 1st Num: ";
- PRINT USING Num$ + ","; TotD1#;
- LOCATE BaseRow% + 4, BaseCol%
- TotD2# = TotD2# + D2#
- PRINT "Sum 2nd Num: ";
- PRINT USING Num$ + ","; TotD2#;
-
- IF NOT Ans# = 0 THEN
- 'BEEP
- LOCATE BaseRow% + 5, BaseCol%
- PRINT "Num Errors:"; ErrorCount&
- SumAns# = SumAns# + Ans#
- LOCATE BaseRow% + 6, BaseCol%
- PRINT "Sum Errors: ";
- PRINT USING "#." + Num$; SumAns#;
- 'SUB LapsedTimer (Row%, Col%, Colr%)
- 'need to change so it senses restarting timer
- IF ErrorCount& = 1 THEN
- ReStart% = True
- END IF
- CALL LapsedTimer(12, 61, 59)
-
- END IF
-
- IF ErrorCount& > 200 THEN
-
- Row% = BaseRow% + 9: Col% = 0: Outline% = 0: Shadow% = False: Length% = False
- Message$ = "{Ctrl}+{BREAK} to ABORT"
- COLOR 14, 2
- CALL TextBoxShadow(Row%, Col%, Message$, Outline%, Shadow%, Length%)
-
- END IF
- NEXT
- 'STOP
- END SUB
-
- SUB Splash1
- Q$ = CHR$(34)
- COLOR 11, 1:
- PRINT
- PRINT " ███████┐ ███████┐ ██████┐ ██┐ ████████┐ ████┐ ██┐ ██┐ ██████████┐ ";
- PRINT " ██┌──██│ ██┌────┘ ██┌─██│ ██│ └──██┌──┘ └██┌┘ ██│ ██│ ██┌─██┌─██│ ";
- PRINT " ███████│ █████┐ ██│ ██│ ██│ ██│ ██│ ██│ ██│ ██│ ██│ ██│ ";
- PRINT " ██┌────┘ ██┌──┘ ██│ ██│ ██│ ██│ ██│ ██│ ██│ ██│ ██│ ██│ ";
- PRINT " ██│ ███████┐ ██│ ██████│ ██│ ████┐ ███████│ ██│ ██│ ██│ ";
- PRINT " └─┘ └──────┘ └─┘ └─────┘ └─┘ └───┘ └──────┘ └─┘ └─┘ └─┘ ";
- COLOR 15, 1:
- PRINT " Much ado about the discovery that the INTEL Pentium chip.... like ";
- PRINT " all CPUs... makes long division math errors. The Internet community ";
- PRINT " is up in arms. The formula (in: NY Times 11/24/1994) which gives a ";
- PRINT " PENTIUM chip error with two (2) =particular= numbers is: ";
- PRINT " ";
- PRINT " Answer = 4,195,835 -[(4,195,835 / 3,145,727) * 3,145,727] ";
- COLOR 14, 1:
- PRINT " (FirstNumber) (SecondNumber) ";
- COLOR 15, 1:
- PRINT "";
- PRINT " The Answer is Zero (0) because you divide -then- multiply one ";
- PRINT " number by a second number. With a Pentium chip, the answer with ";
- PRINT " -these numbers- is "; 256; " or an error of 256/4,195,835 or ";
- PRINT " 61/100,000. This program generates from one to millions of RANDOM ";
- PRINT " numbers using the same, simple formula to show you that your very ";
- PRINT " own beloved computer will do just what the INTEL Pentium chip ";
- PRINT " does.... give you long division errors.";
- PRINT " ";
- COLOR 14, 1: PRINT " John De Palma on CompuServe 76076,571 ";
- COLOR 15, 1: PRINT " ";
- COLOR 7, 0
-
- END SUB
-
- SUB Splash2 (Choice%)
- 'prints a full screen of: ⌠⌠⌠⌠⌠⌠⌠⌠
- ' ⌡⌡⌡⌡⌡⌡⌡⌡
-
- SELECT CASE Choice%
- CASE 1
- Char1% = 244
- Char2% = 245
- CASE 2
- Char1% = 174
- Char2% = 175
- CASE 3
- Char1% = 242
- Char2% = 243
- CASE 4
- Char1% = 47
- Char2% = 92
- CASE 5
- Char1% = 220
- Char2% = 240
- CASE 6
- Char1% = 221
- Char2% = 222
- CASE 7
- Char1% = 180
- Char2% = 195
- CASE 8
- Char1% = 254
- Char2% = 222
- CASE 9
- Char1% = 146
- Char2% = 158
- CASE 10
- Char1% = 159
- Char2% = 159
- CASE ELSE
- Char1% = 244
- Char2% = 245
- END SELECT
-
- FOR i = 1 TO 25 STEP 2
- LOCATE i, 1
- PRINT STRING$(80, Char1%);
- NEXT
- FOR i = 2 TO 24 STEP 2
- LOCATE i, 1
- PRINT STRING$(80, Char2%);
- NEXT
-
- END SUB
-
- SUB TextBoxShadow (Row%, Col%, Message$, Outline%, Shadow%, Length%)
-
- 'Adding other ancillary SUBs as "GOSUB"s so that they
- 'do not need to be imported into a new module.
- 'edited to omit the SUB TwoColr(Fgd%,Bkg,Colr%)
- 'and tested Sun 08-21-1994 21:25:34
-
- 'got to have a REDIM SHARED Box$(1 to 56) in main module
- 'Other SUB/FUNCTIONs still needed for this SUB are:
- 'SUB
- 'LocateIt(Row%, Text$)
- 'FUNCTION
- 'Center% (text$)
- '
- 'Puts a message into a three line box -or-
- 'draw a box without a message using Message$=SPACE$(x)
- 'where "x" is the width of the box and Length%= number of lines > 3
- 'Boxes are centered if Col% = 0; else left side of box = Col%.
- 'Boxes display a true shadow if Shadow% <> 0
- 'True = -1: False = 0
-
- STATIC BoxReadFlag
- Message$ = LEFT$(Message$, 60)
- BoxWidth% = LEN(Message$) + 4
- SELECT CASE Outline%
- CASE 0
- j = 8 * 6 + 1
- CASE 1
- j = 1
- CASE 2
- j = 8 + 1
- CASE 3
- j = 8 * 2 + 1
- CASE 4
- j = 8 * 3 + 1
- CASE 5
- j = 8 * 4 + 1
- CASE 6
- j = 8 * 5 + 1
- CASE ELSE
- j = 8 * 6 + 1
- END SELECT
-
- IF BoxReadFlag THEN GOTO Skip
- REDIM Box$(1 TO 56)
- BoxReadFlag = True
-
- 'single line box
- Box$(1) = "┌"
- Box$(2) = "─"
- Box$(3) = "┐"
- Box$(4) = "│"
- Box$(5) = "│"
- Box$(6) = "└"
- Box$(7) = "─"
- Box$(8) = "┘"
-
- 'double top box
- Box$(9) = "╒"
- Box$(10) = "═"
- Box$(11) = "╕"
- Box$(12) = "│"
- Box$(13) = "│"
- Box$(14) = "╘"
- Box$(15) = "═"
- Box$(16) = "╛"
-
- 'double side box
- Box$(17) = "╓"
- Box$(18) = "─"
- Box$(19) = "╖"
- Box$(20) = "║"
- Box$(21) = "║"
- Box$(22) = "╙"
- Box$(23) = "─"
- Box$(24) = "╜"
-
- 'double box
- Box$(25) = "╔"
- Box$(26) = "═"
- Box$(27) = "╗"
- Box$(28) = "║"
- Box$(29) = "║"
- Box$(30) = "╚"
- Box$(31) = "═"
- Box$(32) = "╝"
-
- 'bold box
- Box$(33) = "█"
- Box$(34) = "▀"
- Box$(35) = "█"
- Box$(36) = "█"
- Box$(37) = "█"
- Box$(38) = "█"
- Box$(39) = "▄"
- Box$(40) = "█"
-
- 'bold and thick box
- Box$(41) = "█"
- Box$(42) = "█"
- Box$(43) = "█"
- Box$(44) = "█"
- Box$(45) = "█"
- Box$(46) = "█"
- Box$(47) = "█"
- Box$(48) = "█"
-
- 'no box
- Box$(49) = " "
- Box$(50) = " "
- Box$(51) = " "
- Box$(52) = " "
- Box$(53) = " "
- Box$(54) = " "
- Box$(55) = " "
- Box$(56) = " "
-
- Skip:
-
-
-
- IF Col% = 0 THEN
-
- BoxText$ = Box$(j) + STRING$(BoxWidth%, Box$(j + 1)) + Box$(j + 2)
- GOSUB Location
- 'CALL LocateIt(Row%, BoxText$)
- Row2% = CSRLIN: Col2% = POS(0)
- Colr% = SCREEN(Row2%, Col2% - 1, 1)
- 'GOSUB GetTwoColors
- CALL TwoColrs(Fgd%, Bkg%, Colr%)
-
- FOR i = 1 TO Length% + 1
- BoxText$ = Box$(j + 3) + " " + Message$ + " " + Box$(j + 4)
- 'GOSUB Location
- CALL LocateIt(Row% + i, BoxText$)
-
- IF Shadow% THEN
- COLOR 7, 0
- FOR k = 1 TO 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- COLOR Fgd%, Bkg%
- END IF
- NEXT i
-
- BoxText$ = Box$(j + 5) + STRING$(BoxWidth%, Box$(j + 6)) + Box$(j + 7)
- 'GOSUB Location
- CALL LocateIt(Row% + i, BoxText$)
-
- IF Shadow% THEN
- COLOR 7, 0
- FOR k = 1 TO 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- 'COLOR Fgd%, Bkg%
-
- COLOR 7, 0
- LOCATE Row% + i + 1, Center(BoxText$) + 2
-
- FOR k = 1 TO BoxWidth% + 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- COLOR Fgd%, Bkg%
- END IF
- ELSE
-
- BoxText$ = Box$(j) + STRING$(BoxWidth%, Box$(j + 1)) + Box$(j + 2)
- LOCATE Row%, Col%
- PRINT BoxText$;
- Row2% = CSRLIN: Col2% = POS(0)
- Colr% = SCREEN(Row2%, Col2% - 1, 1)
- GOSUB GetTwoColors
- 'CALL TwoColrs(Fgd%, Bkg%, Colr%)
-
- FOR i = 1 TO Length% + 1
- BoxText$ = Box$(j + 3) + " " + Message$ + " " + Box$(j + 4)
- LOCATE Row% + i, Col%
- PRINT BoxText$;
-
- IF Shadow% THEN
- COLOR 7, 0
- FOR k = 1 TO 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- COLOR Fgd%, Bkg%
- END IF
-
- NEXT i
-
- BoxText$ = Box$(j + 5) + STRING$(BoxWidth%, Box$(j + 6)) + Box$(j + 7)
- LOCATE Row% + i, Col%
- PRINT BoxText$;
-
- IF Shadow% THEN
- COLOR 7, 0
- FOR k = 1 TO 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
-
- LOCATE Row% + i + 1, Col% + 2
- FOR k = 1 TO BoxWidth% + 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- COLOR Fgd%, Bkg%
- END IF
-
- END IF
- EXIT SUB
- GetTwoColors:
- Fgd% = (Colr% AND 128) \ 8 + (Colr% AND 15)
- Bkg% = (Colr% AND 112) \ 16
- RETURN
-
- Location:
- LOCATE Row%, 41 - (LEN(BoxText$)) \ 2
- PRINT BoxText$;
- RETURN
-
- END SUB
-
- SUB TextInput (text$, MaxLen%) STATIC
-
- 'Set up cursor, line, and maximum characters to enter:
-
- y% = CSRLIN
- LOCATE , , 1
- IF MaxLen% > (79 - POS(0)) THEN MaxLen% = (79 - POS(0))
- 'STOP
- 'Display default text:
- COLOR 11, 0
- 'Row% = CSRLIN
- 'Col% = POS(0)
- 'PRINT text$;
- 'LOCATE Row%, Col%
- DO
- i$ = INKEY$
-
- SELECT CASE LEFT$(i$, 1)
- CASE CHR$(8) 'Backspace
- 'STOP
- IF text$ > "" THEN
- text$ = LEFT$(text$, LEN(text$) - 1)
- LOCATE y%, POS(0) - 1
- PRINT " ";
- LOCATE , POS(0) - 1
- END IF
-
- CASE CHR$(32) TO CHR$(255) 'Valid characters
- 'STOP
- IF LEN(text$) <= MaxLen% THEN
- PRINT LEFT$(i$, 1);
- text$ = text$ + LEFT$(i$, 1)
- ELSE
- BEEP
- END IF
-
- CASE "", CHR$(13) 'Null or carriage return
-
- CASE ELSE 'Non-printables, etc.
- BEEP
- END SELECT
-
- LOOP UNTIL i$ = CHR$(13)
- LOCATE , , 0
- PRINT
- END SUB
-
- SUB TwoColrs (Fgd%, Bkg%, Colr%)
-
- Fgd% = (Colr% AND 128) \ 8 + (Colr% AND 15)
- Bkg% = (Colr% AND 112) \ 16
-
- END SUB
-
- FUNCTION YesNo2% (Answer$) STATIC
- 'STOP
-
- WHILE INKEY$ <> "": WEND
-
- DO
- YN$ = INKEY$
- LOOP UNTIL LEN(YN$)
- IF YN$ = CHR$(27) THEN END
-
- YesNo2% = INSTR(Answer$, YN$) 'Answer$ is the search string
-
- 'COMMANDS TO CALL THIS FUNCTION:
- 'Answer$ = "yY" + CHR$(13) + "nN" 'neat to use {Enter}
- 'IF YesNo2% > 0 AND YesNo2% < 4 THEN GOTO Again
- 'IF YesNo2% <= 0 OR YesNo2% > 3 THEN PRINT "E"
- 'can use a function key as:
- 'F1$ = CHR$(0)+";"
-
- END FUNCTION
-
-